﻿@model N03_11HCA_HTTTHD.Models.Admin_QuanLyCanBan
@{
    ViewBag.Title = "Ban quản trị";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

@section TimKiemImport{
    <div class="filtering">
        <label for="tenViet">Tên Việt: </label>
        <input type="text" name="tenViet" id="tenViet" />
        <label for="tenAnh">Tên Anh: </label>
        <input type="text" name="tenAnh" id="tenAnh" />
        <label for="nguoiDang">Người đăng: </label>
        <select id="nguoiDang" name="nguoiDang">
            <option selected="selected" value="0">Tất cả</option>
            @for (int i = 0; i < Model.ListTaiKhoan.Count; i++)
            {
                <option value="@Model.ListTaiKhoan[i].ID">@Model.ListTaiKhoan[i].TenDangNhap</option>
            }
        </select>
        <label for="loaiCanBan">Loại cần bán: </label>
        <select id="loaiCanBan" name="loaiCanBan">
            <option selected="selected" value="0">Tất cả</option>
            <option value="1">Thiết bị</option>
            <option value="2">Dịch vụ</option>
            <option  value="3">Phần mềm</option>
        </select>

        <button type="submit" id="LoadRecordsButton">Lọc dữ liệu</button>
</div>
}

@section JavaScriptCSSImport{
    <link href="@Url.Content("~/Content/mycontent/list_counter.css")" rel="stylesheet" type="text/css"/>
}

@section JavaScriptDocumentReady{
    $('#danhSachCanBan').jtable({
            tableId: "tableCanBan",
            title: 'Danh sách cần bán',
            pageSize: 20,
            paging: true,
            sorting: true,
            defaultSorting: 'TenViet DESC',
            selecting: true, //Enable selecting
            //multiselect: true, //Allow multiple selecting
            //selectingCheckboxes: true, //Show checkboxes on first column
            //selectOnRowClick: false, //Enable this to only select using checkboxes
            actions: {
                listAction: '/Admin/DanhSachCanBan',
                deleteAction: '/Admin/XoaCanBan',
                updateAction: '/Admin/CapNhatCanBan',
                createAction: '/Admin/ThemCanBan'
            },

            fields: {
                ID: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false
                },
                HinhAnhDinhKem : {
                    title: 'Hình ảnh đính kèm ',
                    create: false,
                    edit: true,
                    list: false,
                    sorting: true

                },
                IDChuyenGiao : {
                    title: 'Chuyển giao',                   
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false                    
                },
                 IDDichVu : {
                    title: 'Dịch vụ',                   
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false                    
                },
                IDNguoiDang: {
                    title: 'Người đăng',                   
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false                    
                },
                IDPhanMem: {
                    title: 'Phần mềm',                   
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false                    
                },
                IDThietBi: {
                    title: 'Thiết bị',                   
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false                    
                },
               
                MoTa: {
                    title: 'Mô tả',
                    type: 'textarea',
                    create: true,
                    edit: true,
                    list: false,
                    sorting: false                   
                },
                TenViet: {
                    title: 'Tên việt',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true                    
                },
                TenAnh: {
                    title: 'Tên anh',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true                  
                },
                 XuatXu: {
                    title: 'Xuất xứ',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true                    
                },
                   UuDiem: {
                    title: 'Ưu điểm',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true                    
                }, 
                 LoaiCanBan: {
                    title: 'Loại cần bán',     
                    options:{"1":"Thiết bị","2":"Dịch vụ","3":"Phần mềm"},
                    create: true,
                    edit: false,
                    list: true,
                    sorting: true                    
                },                            
                Xoa: {
                    title: 'Trạng thái',
                    create: false,
                    edit: true,
                    list: true,
                    sorting: true,
                    type: 'checkbox',
                    values: { 'false': 'Hoạt động', 'true': 'Bị xóa' },
                },
                TepTinDinhKem: {
                    title: 'Tên tin đính kèm',                    
                    create: false,
                    edit: false,
                    list: false,
                    sorting: true                    
                },
                TuKhoa: {
                    title: 'Từ khóa',
                    create: true,
                    edit: true,
                    list: false,
                    sorting: true                    
                }             
            }
        });

        //Load student list from server
        $('#danhSachCanBan').jtable('load');
        //$('table.jtable').css("table-layout","fixed");

         //Filter
        //Re-load records when user click 'load records' button.
        $('#LoadRecordsButton').click(function (e) {
            e.preventDefault();
            $('#danhSachCanBan').jtable('load', {
                tenViet: $('#tenViet').val(),
                tenAnh: $('#tenAnh').val(),
                nguoiDang: $('#nguoiDang').val(),
                loaiCanBan: $('#loaiCanBan').val(),
                
            });
        });
}

<!-- Container for jTable -->
<div id="danhSachCanBan"></div>